<template>
	<view class="content">
		<view v-if="identity==2&&conditionDetail.state==1&&type!=1" class="btn" @click="goApply">在线预订</view>
		<view class="block list-block">
			<view class="detail-block">
				<view class="title">{{conditionDetail.title}}</view>
				<view class="time">
					<image class="imgs" :src="imageUrl+'/job_hunting/job_fair/time.png'"></image><text
						class="sub-title">举办时间：</text>{{conditionDetail.eventTimeStart}}至{{conditionDetail.eventTimeEnd}}
				</view>
				<view class="time">
					<image class="imgs" :src="imageUrl+'/job_hunting/job_fair/main.png'"></image><text
						class="sub-title">主办单位：</text>{{conditionDetail.organizer}}
				</view>
				<view class="time">
					<image class="imgs" :src="imageUrl+'/job_hunting/job_fair/accept.png'"></image><text
						class="sub-title">承办单位：</text>{{conditionDetail.organizerTake}}
				</view>
				<view class="time">
					<image class="imgs" :src="imageUrl+'/job_hunting/job_fair/assist.png'"></image><text
						class="sub-title">协办单位：</text>{{conditionDetail.organizerCo}}
				</view>
			</view>
			<view class="detail-count" v-if="type!=1">
				<view class="label-title">企业<text class="count">{{conditionDetail.qyCount}}</text>家</view>
				<view class="label-title2">职位<text class="count">{{conditionDetail.zwCount}}</text>个</view>
				<!-- <view class="label-title2">岗位数<text class="count">{{conditionDetail.count[2]}}</text>个</view> -->
				<view class="label-title2">简历<text class="count">0</text>个</view>
				<view class="label-titlenoBorder">浏览<text class="count">{{conditionDetail.browseNumber}}</text>次</view>
			</view>

			<view class="detail-count">
				<view class="block tab-block">
					<view @click="selectTabActive(1)" :class="tabActive==1?'active':''" class="tab-item">活动介绍</view>
					<view v-if="type!=1" @click="selectTabActive(2)" :class="tabActive==2?'active':''" class="tab-item">
						参会企业</view>
					<view v-else @click="selectTabActive(3)" :class="tabActive==3?'active':''" class="tab-item">参会岗位
					</view>
					<view v-if="tabActive==1" class="article-content">
						<mp-html :content="conditionDetail.eventIntro" />
					</view>
					<view v-if="tabActive==2" class="block list-block">
						<template v-if="list.length>0">
							<view
								@click="navigate('/page_other/job_hunting/job_fair/job_company?cid='+item.id+'&sid='+conditionDetail.id)"
								class="list-item" v-for="(item,index) in list" :key="item.id">
								<image
									:src="item.logoUrl ? item.logoUrl : imageUrl+'/job_hunting/job_detail/enterprise.jpg'"
									class="cover-photo"></image>
								<view class="list-info">
									<view class="title">{{item.brandName}}</view>
									<view class="address">
										<view class="add" v-if="item.enterpriseName">{{item.enterpriseName}}</view>
										<view class="add" v-else style="margin-left: 0px;">暂无企业类型</view>
										<view class="add">/ {{item.scaleName}}</view>
									</view>
									<!-- <view class="label-block">
										<view class="label-item" v-for="label in item.label">{{label}}</view>
									</view> -->
									<view class="positionCount"><text
											style="color: blue;">{{item.fairCount}}</text>个热招职位
									</view>
								</view>
							</view>
						</template>
						<!-- 底部加载提示 -->
						<view v-else class="block list-block">
							<view class="empty">暂无数据</view>
						</view>

					</view>
					<view v-if="tabActive==3" class="block list-block">
						<template v-if="jobList.length>0">
							<view
								@click="navigate('/page_other/job_hunting/job_detail/index?id='+item.id+'&jobType='+item.jobType)"
								class="list-item" v-for="(item,index) in jobList" :key="item.id">
								<view class="list-info">
									<view class="title">{{item.jobTitle}}</view>
									<view class="address">{{item.jobAddress}}</view>
									<view class="label-block">
										<view class="label-item" v-for="label in item.welfareList">{{label}}</view>
									</view>
									<view class="wage" v-if="item.minSalary">{{item.minSalary}}-{{item.maxSalary}}<text
											class="unit">元</text></view>
									<view class="wage" v-else>面议</view>
								</view>
							</view>
						</template>
					</view>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		findAllByIdApi,
		getByFairApi,
		getEnterpriseDetailsApi
	} from '@/api/job.js';
	import {
		getStorage
	} from '@/util/auth.js';
	import util from '@/util/util.js'
	export default {
		data() {
			return {
				id: null,
				imageUrl: '',
				tabActive: 1,
				type: null,
				//参会企业列表
				page: 1,
				limit: 10,
				loadend: false,
				loading: false,
				loadTitle: '加载更多',
				list: [],
				conditionDetail: {
					title: '',
					eventTimeStart: '',
					eventTimeEnd: '',
					endTeventTimeEndime: '',
					organizer: '',
					organizerTake: '',
					organizerCo: '',
					qyCount: 0,
					zwCount: 0
				},
				jobList: [],
				sid: null,
				cid: null
			}
		},
		methods: {
			navigate(url) {
				if (this.$store.getters.identity == 1) {
					uni.navigateTo({
						url
					})
				}

			},
			selectTabActive(e) {
				this.tabActive = e

				if (e == 2) {
					this.getList();
				}
			},

			goApply() {
				uni.navigateTo({
					url: '/page_other/job_hunting/job_fair/position?id=' + this.id
				})
			},

			//查询活动介绍
			findAllById() {
				findAllByIdApi({
					id: this.id
				}).then((res) => {
					this.conditionDetail = res;
				}).catch((res) => {
					console.log(res)
				})
			},

			//参会企业列表
			getList() {
				uni.showLoading({
					title: '正在加载数据',
					mask: true
				})

				getByFairApi({
					sId: this.id
				}).then((res) => {
					uni.hideLoading()
					this.list = res ?? []
				})
			},
			//参会岗位列表
			getEnterpriseDetails() {
				getEnterpriseDetailsApi({
					sId: this.sid,
					cId: this.cid
				}).then((res) => {
					this.jobList = res.jobPublishList ?? [];
					console.log(this.jobList)
				})
			},
		},
		computed: {
			identity() {
				return this.$store.getters.identity
			}
		},
		onLoad(e) {
			console.log(e)
			this.imageUrl = this.globalConfig.imageUrl;
			this.id = e.id;
			this.type = e.type
			this.sid = e.sid
			this.cid = e.cid
			console.log(this.type)
			uni.setNavigationBarTitle({
				title: e.name
			})

			this.findAllById();
		},

		onShow() {


		},
	}
</script>

<style lang="scss">
	$box-shadow: 0 0 10px 0 #efefef;

	page {
		background: #FAFAFA;
	}

	.content {
		width: 100%;
		padding: 0 30rpx;

		.loadingicon {
			width: 100%;
			height: 80rpx;
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			justify-content: center;
		}

		.loading {
			width: 100%;
			height: 100rpx;
			line-height: 100rpx;
			align-items: center;
			justify-content: center;
			position: relative;
			text-align: center;
		}

		.loading .line {
			position: absolute;
			width: 450rpx;
			left: 150rpx;
			top: 50rpx;
			height: 1px;
			border-top: 1px solid #eee;
		}

		.loading .text {
			position: relative;
			display: inline-block;
			padding: 0 20rpx;
			background: #fff;
			z-index: 2;
			color: #777;
		}

		.loadingicon .loading {
			animation: load linear 1s infinite;
			font-size: 45rpx;
			color: #000;
		}

		.loadingicon {
			width: 100%;
			height: 80rpx;
		}

		.btn {
			width: 50%;
			height: 80rpx;
			line-height: 80rpx;
			border-radius: 80rpx;
			text-align: center;
			color: #fff;
			background-color: #ff7626;
			font-size: 32rpx;
			font-weight: bold;
			position: fixed;
			bottom: 30rpx;
			left: calc(50% / 2);
			right: calc(50% / 2);
			border-left: 5px solid transparent;
			border-right: 5px solid transparent;
			z-index: 9999999 //margin: 655px 72px;
		}

		.block.tab-block {
			box-shadow: none;
			display: flex;
			flex-direction: row;
			justify-content: left;
			flex-wrap: wrap;
			width: 100%;

			.article-content {
				font-size: 27rpx;
				line-height: 50rpx;
				margin-top: 30rpx;
			}

			.list-block.block {
				margin-top: 30rpx;
				width: 100%;
				display: flex;
				flex-direction: column;

				.company-item {
					.company-name {
						display: flex;
						align-items: center;
						justify-content: space-between;
						padding: 30rpx 0 20rpx 0;

						.name-block {
							display: flex;
							align-items: center;
							font-weight: bold;

							.line {
								width: 15rpx;
								height: 35rpx;
								border-radius: 16rpx;
								background-color: #FE7526;
								margin-right: 10rpx;
							}
						}

						.more {
							color: #999;
							font-size: 30rpx;
						}
					}
				}

				.list-item {
					width: 100%;
					background: #FAFAFA;
					border-radius: 10rpx;
					box-shadow: 0 0 10px 0 #efefef;
					padding: 20rpx;
					display: flex;
					flex-direction: row;
					justify-content: center;
					margin: 20rpx auto;

					.cover-photo {
						width: 25%;
						height: 150rpx;
						background: #efefef;
						margin-right: 20rpx;
						border-radius: 20rpx;

					}

					.list-info {
						width: 70%;
						display: flex;
						flex-direction: column;

						view {
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}

						.title {
							color: #000;
							font-weight: bold;
							font-size: 34rpx;
						}

						.address {
							display: flex;
							flex-direction: row;

							.add {
								color: #999;
								font-size: 26rpx;

							}
						}

						.city {
							color: #999;
							font-size: 26rpx;
							margin-left: 4rpx;
						}

						.imgs2 {
							width: 17px;
							height: 17px;
							margin-left: 70rpx;
							vertical-align: bottom;
						}

						.positionCount {
							font-size: 28rpx;
							margin-top: 15rpx;
						}

						.label-block {
							font-size: 24rpx;
							display: flex;
							flex-direction: row;
							flex-wrap: wrap;
							justify-content: left;
							margin-top: 20rpx;

							.label-item {
								padding: 8rpx 20rpx;
								background: #F5F6F8;
								color: #999;
								margin: 0 10rpx 20rpx 0;
							}
						}

						.wage {
							color: #FE7526;
							font-size: 36rpx;
							font-weight: bold;

							.unit {
								font-size: 28rpx;
								font-weight: normal;
							}
						}
					}
				}

				.list-item.policy-item {
					height: 220rpx;
					width: 100%;
					padding: 30rpx 0;
					display: flex;
					flex-direction: row;
					border-radius: 20rpx;
					background: #fff;
					margin-bottom: 30rpx;
					padding: 20rpx;
					box-shadow: 0 0 10px 0 #efefef;

					.cover-photo {
						width: 180rpx;
						height: 180rpx;
						border-radius: 10rpx;
						margin-right: 20rpx;
						background: #efefef;
					}

					.info {
						width: calc(100% - 200rpx);
						height: 100%;

						.title {
							font-weight: bold;
						}

						.abstract {
							font-size: 24rpx;
							color: #999;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;
							overflow: hidden;
							margin-top: 10rpx;
							line-height: 1.5;
						}

						.time {
							margin-top: 10rpx;
							font-size: 28rpx;
							color: #999;
						}
					}
				}

				.detail-block {
					width: 100%;
					padding: 30rpx;
					margin: auto auto 30rpx auto;
					background-color: #fff;

					.title {
						font-size: 34rpx;
						font-weight: bold;
						margin-bottom: 30rpx;
					}

					.sub-title {
						font-size: 28rpx;
						color: #999;
						margin-bottom: 30rpx;
					}

					.article-content {
						font-size: 30rpx;
						line-height: 60rpx;
					}
				}

				.apply-btn {
					width: 50%;
					height: 70rpx;
					line-height: 70rpx;
					background-color: #ff7626;
					color: #fff;
					text-align: center;
					border-radius: 100rpx;
					margin: 40rpx auto;
				}

				.list-item {
					width: 100%;
					background: #fff;
					border-radius: 10rpx;
					box-shadow: $box-shadow;
					padding: 20rpx;
					display: flex;
					flex-direction: row;
					justify-content: center;
					margin-bottom: 20rpx;

					.list-info {

						display: flex;
						flex-direction: column;

						view {
							width: 100%;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}

						.title {
							color: #000;
							font-weight: bold;
							font-size: 34rpx;
						}

						.address {
							color: #999;
							font-size: 26rpx;
							margin-top: 20rpx;
						}

						.label-block {
							font-size: 24rpx;
							display: flex;
							flex-direction: row;
							flex-wrap: wrap;
							justify-content: left;
							margin-top: 20rpx;

							.label-item {
								padding: 8rpx 20rpx;
								background: #F5F6F8;
								color: #999;
								margin: 0 10rpx 20rpx 0;
							}
						}

						.wage {
							color: #FE7526;
							font-size: 36rpx;
							font-weight: bold;

							.unit {
								font-size: 28rpx;
								font-weight: normal;
							}
						}
					}
				}
			}

			.tab-item {
				padding: 10rpx 15rpx;
				font-weight: bold;
				font-size: 30rpx;
				margin-right: 30rpx;
			}

			.tab-item.active {
				background: url("https://job-1306862033.cos.ap-chengdu.myqcloud.com/miniprogram-static/job_hunting/home/tab_selected_bg.png") no-repeat right bottom;
				background-size: 45%;
				font-size: 32rpx;
			}
		}

		.detail-block {
			width: 100%;
			padding: 30rpx;
			margin: auto auto 30rpx auto;
			background-color: #fff;
			border-radius: 20rpx;

			.time {
				margin-top: 10rpx;
				font-size: 25rpx;

			}

			.title {
				font-size: 34rpx;
				font-weight: bold;
				margin-bottom: 30rpx;
				border-bottom: 1px solid #efefef;
				padding-top: 32rpx;
			}

			.sub-title {
				font-size: 25rpx;
				color: #999;
				margin-bottom: 30rpx;
				padding-left: 10rpx;
				align-items: center;

			}

			.imgs {
				width: 30rpx;
				height: 30rpx;
				vertical-align: middle;
			}

		}

		.detail-count {
			width: 100%;
			padding: 30rpx;
			margin: auto auto 30rpx auto;
			background-color: #fff;
			border-radius: 20rpx;
			display: flex;

			.label-title {
				width: 180rpx;
				border-right: 1px solid #efefef;
				font-size: 26rpx;
			}

			.label-title2 {
				width: 180rpx;
				border-right: 1px solid #efefef;
				font-size: 26rpx;
				text-align: center;

			}

			.label-titlenoBorder {
				width: 180rpx;
				font-size: 26rpx;
				margin-left: 20rpx;
				text-align: center;
			}

			.count {
				color: #ff7626;
				font-size: 32rpx;
				font-weight: bold;

			}
		}



	}
</style>